//马原
var single = document.getElementsByClassName("singleAnswer");
var many = document.getElementsByClassName("manyAnswer");
var judge = document.getElementsByClassName("correctAnswer");
var i = 0;
var choose = '';
var time613 = new Date();
time613.setTime(time613.setHours(time613.getHours() + 2));

function randomFrom(lowerValue, upperValue) {
    return Math.floor(Math.random() * (upperValue - lowerValue + 1) + lowerValue);
}

function getTime613() {
    var t = time613;
    t.setTime(t.setSeconds(t.getSeconds() + randomFrom(5, 60)));
    time613 = t;
    console.log(new Date(time613));
    return t.getTime();
}

function isEqualsCourseAjax(curr, courseId) {
    $(curr).bind("click", function() {
        $.ajax({
            url: "isCurrentCourseInfoIdAjax.action?d=" + getTime613(),
            type: "post",
            async: false,
            data: { "courseInfoId": courseId },
            dataType: "json",
            success: function(data) {
                if (data.isEquals == 1) {
                    top.location.href = "exit.action?message=clearCourse";

                } else if (data.isEquals == 2) {
                    top.location.href = "exit.action?message=equalsCourse";
                }
            }
        });
    });
}


$(document).ready(function() {
    var isEqualsCourse = function() {
        var courseId = "5000000310";
        if ("" == courseId) {
            return;
        } else {
            isEqualsCourseAjax(this, courseId);
            $("iframe").each(function() {
                $(this).bind("load", function() {
                    var current = this.contentWindow.document.body;
                    isEqualsCourseAjax(current, courseId);
                })

            });
        }
    };
    isEqualsCourse();
});


for (i = 0; i < single.length; i++) {
    choose = $(single[i]).val();
    $(".dxt[value$='" + choose + "']").click();
}
for (i = 0; i < many.length; i++) {
    choose = $(many[i]).val();
    $(".radio_name_new[value$='" + choose + "']").click();
}
for (i = 0; i < judge.length; i++) {
    choose = $(judge[i]).val();
    $(".radio_name[value$='" + choose + "']").click();
}